
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>6.2 匹配模式 pattern · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="css/default.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="rule-opv.html" />
    
    
    <link rel="prev" href="rule-model.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    1. xProxy 是什么？
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="good.html">
            
                <a href="good.html">
            
                    
                    1.1 xProxy 的优势
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.2" data-path="charles-diff.html">
            
                <a href="charles-diff.html">
            
                    
                    1.2 与 Charles 对比
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="INSTALL.html">
            
                <a href="INSTALL.html">
            
                    
                    2. xProxy 安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    3. 面板说明
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="panel-main.html">
            
                <a href="panel-main.html">
            
                    
                    3.1 首页面板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="panel-network.html">
            
                <a href="panel-network.html">
            
                    
                    3.2 Network 网络面板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="panel-rule.html">
            
                <a href="panel-rule.html">
            
                    
                    3.3 Rules 规则面板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="panel-value.html">
            
                <a href="panel-value.html">
            
                    
                    3.4 Values 值面板
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="start.html">
            
                <a href="start.html">
            
                    
                    4. 快速开始
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="frequent.html">
            
                <a href="frequent.html">
            
                    
                    4.1 常用功能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="fit-recore.html">
            
                <a href="fit-recore.html">
            
                    
                    4.2 适配 Recore
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="fit-go.html">
            
                <a href="fit-go.html">
            
                    
                    4.3 适配乐高
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    5. 迁移
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="ihost.html">
            
                <a href="ihost.html">
            
                    
                    5.1 iHost 迁移
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="xswitch.html">
            
                <a href="xswitch.html">
            
                    
                    5.2 xSwitch 迁移
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="charles-m.html">
            
                <a href="charles-m.html">
            
                    
                    5.3 Charles 迁移
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    6. 规则
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="rule-model.html">
            
                <a href="rule-model.html">
            
                    
                    6.1 配置方式
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6.2" data-path="rule-pattern.html">
            
                <a href="rule-pattern.html">
            
                    
                    6.2 匹配模式 pattern
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="rule-opv.html">
            
                <a href="rule-opv.html">
            
                    
                    6.3 操作值 opValue
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="rule-opp.html">
            
                <a href="rule-opp.html">
            
                    
                    6.4 匹配原则 opProtocol
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="mobile.html">
            
                <a href="mobile.html">
            
                    
                    7. 移动端接入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="qa.html">
            
                <a href="qa.html">
            
                    
                    8. 常见问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="th.html">
            
                <a href="th.html">
            
                    
                    致谢
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" >
            
                <span>
            
                    
                    反馈
            
                </span>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >6.2 匹配模式 pattern</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x5339;&#x914D;&#x6A21;&#x5F0F;-pattern">&#x5339;&#x914D;&#x6A21;&#x5F0F; pattern</h1>
<p>&#x5E95;&#x5C42;&#x5E93;&#x7684;&#x5339;&#x914D;&#x6A21;&#x5F0F;(pattern)&#x5927;&#x4F53;&#x53EF;&#x4EE5;&#x5206;&#x6210; &#x57DF;&#x540D;&#x3001;&#x8DEF;&#x5F84;&#x3001;&#x6B63;&#x5219;&#x3001;&#x7CBE;&#x786E;&#x5339;&#x914D;&#x3001;&#x901A;&#x914D;&#x7B26;&#x5339;&#x914D;&#xFF1A;</p>
<blockquote>
<p>&#x5176;&#x4E2D; &#x6B63;&#x5219;&#x5339;&#x914D;&#x3001;&#x7CBE;&#x786E;&#x5339;&#x914D;&#x3001;&#x901A;&#x914D;&#x7B26;&#x5339;&#x914D;&#x652F;&#x6301;&#x53D6;&#x975E;&#xFF0C;&#x5373; !pattern&#xFF0C;&#x8868;&#x793A;&#x4E0D;&#x5339;&#x914D; pattern &#x5173;&#x952E;&#x5B57;&#x7B26;&#xFF1A;^&#xFF08;&#x901A;&#x914D;&#x8DEF;&#x5F84;&#x8868;&#x793A;&#x7B26;&#xFF09;&#x3001;$&#xFF08;&#x7CBE;&#x786E;&#x5339;&#x914D;&#xFF09;&#x3001;*&#xFF08;&#x901A;&#x914D;&#x7B26;&#xFF09;&#x3001;!&#xFF08;&#x53D6;&#x975E;&#xFF09;&#x3002;</p>
</blockquote>
<h5 id="&#x57DF;&#x540D;&#x5339;&#x914D;">&#x57DF;&#x540D;&#x5339;&#x914D;</h5>
<p>&#x57DF;&#x540D;&#x5339;&#x914D;&#xFF0C;&#x4E0D;&#x4EC5;&#x652F;&#x6301;&#x5339;&#x914D;&#x67D0;&#x4E2A;&#x57DF;&#x540D;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x9650;&#x5B9A;&#x7AEF;&#x53E3;&#x53F7;&#x3001;&#x534F;&#x8BAE;(<code>http&#x3001;https&#x3001;ws&#x3001;wss&#x3001;tunnel</code>)&#xFF0C;&#x5982;&#x679C;operatorURI&#x4E0D;&#x4E3A;&#x8BF7;&#x6C42;&#x8DEF;&#x5F84;&#xFF0C;pattern&#x548C;operatorURI&#x4F4D;&#x7F6E;&#x53EF;&#x4EE5;&#x8C03;&#x6362;&#xFF1A;</p>
<pre><code class="lang-sh"><span class="hljs-comment"># &#x5339;&#x914D;&#x57DF;&#x540D;www.test.com&#x4E0B;&#x7684;&#x6240;&#x6709;&#x8BF7;&#x6C42;&#xFF0C;&#x5305;&#x62EC;http&#x3001;https&#x3001;ws&#x3001;wss&#xFF0C;tunnel</span>
www.test.com operatorURI

<span class="hljs-comment"># &#x5339;&#x914D;&#x57DF;&#x540D;www.test.com&#x4E0B;&#x7684;&#x6240;&#x6709;http&#x8BF7;&#x6C42;</span>
http://www.test.com operatorURI

<span class="hljs-comment"># &#x5339;&#x914D;&#x57DF;&#x540D;www.test.com&#x4E0B;&#x7684;&#x6240;&#x6709;https&#x8BF7;&#x6C42;</span>
https://www.test.com operatorURI

<span class="hljs-comment"># &#x4E0A;&#x8FF0;&#x5339;&#x914D;&#x4E5F;&#x53EF;&#x4EE5;&#x9650;&#x5B9A;&#x57DF;&#x540D;&#x7684;&#x7AEF;&#x53E3;&#x53F7;</span>
www.test.com:8888 operatorURI <span class="hljs-comment"># 8888&#x7AEF;&#x53E3;</span>
www.test.com/ operatorURI <span class="hljs-comment"># http&#x4E3A;80&#x7AEF;&#x53E3;&#xFF0C;&#x5176;&#x5B83;443&#x7AEF;&#x53E3;</span>
</code></pre>
<p>&#x5176;&#x4E2D;&#xFF0C;tunnel&#x4E3A;Tunnel&#x4EE3;&#x7406;&#x8BF7;&#x6C42;&#x7684;&#x534F;&#x8BAE;&#xFF0C;tunnel&#x534F;&#x8BAE;&#x7684;url&#x53EA;&#x6709;&#x57DF;&#x540D;&#x6CA1;&#x6709;&#x8DEF;&#x5F84;&#x3002;</p>
<h5 id="&#x8DEF;&#x5F84;&#x5339;&#x914D;">&#x8DEF;&#x5F84;&#x5339;&#x914D;</h5>
<p>&#x6307;&#x5B9A;&#x5339;&#x914D;&#x67D0;&#x4E2A;&#x8DEF;&#x5F84;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x9650;&#x5B9A;&#x7AEF;&#x53E3;&#x53F7;&#x3001;&#x534F;&#x8BAE;(http&#x3001;https&#x3001;ws&#x3001;wss)&#x7B49;&#x7B49;&#xFF0C;&#x5982;&#x679C;operatorURI&#x4E0D;&#x4E3A;&#x8BF7;&#x6C42;&#x8DEF;&#x5F84;&#xFF0C;pattern&#x548C;operatorURI&#x4F4D;&#x7F6E;&#x53EF;&#x4EE5;&#x8C03;&#x6362;&#x3002;</p>
<pre><code class="lang-sh"><span class="hljs-comment"># &#x9650;&#x5B9A;&#x8BF7;&#x6C42;&#x534F;&#x8BAE;&#xFF0C;&#x53EA;&#x80FD;&#x5339;&#x914D;http&#x8BF7;&#x6C42;</span>
http://www.test.com/xxx operatorURI
http://www.test.com:8080/xxx operatorURI

<span class="hljs-comment"># &#x5339;&#x914D;&#x6307;&#x5B9A;&#x8DEF;&#x5F84;&#x4E0B;&#x7684;&#x6240;&#x6709;&#x8BF7;&#x6C42;</span>
www.test.com/xxx operatorURI
www.test.com:8080/xxx operatorURI
</code></pre>
<p>&#x8DEF;&#x5F84;&#x5339;&#x914D;&#x4E0D;&#x652F;&#x6301;tunnel&#x534F;&#x8BAE;&#x7684;url&#x3002;</p>
<h5 id="&#x6B63;&#x5219;&#x5339;&#x914D;">&#x6B63;&#x5219;&#x5339;&#x914D;</h5>
<p>&#x6B63;&#x5219;&#x7684;&#x8BED;&#x6CD5;&#x53CA;&#x5199;&#x6CD5;&#x8DDF;js&#x7684;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x4E00;&#x81F4;&#xFF0C;&#x652F;&#x6301;&#x4E24;&#x79CD;&#x6A21;&#x5F0F;&#xFF1A;/reg/&#x3001;/reg/i &#x5FFD;&#x7565;&#x5927;&#x5C0F;&#x5199;&#xFF0C;&#x652F;&#x6301;&#x5B50;&#x5339;&#x914D;&#xFF0C;&#x4F46;&#x4E0D;&#x652F;&#x6301;<del>/reg/g</del>&#xFF0C;&#x4E14;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x6B63;&#x5219;&#x7684;&#x5B50;&#x5339;&#x914D;&#x628A;&#x8BF7;&#x6C42;url&#x91CC;&#x9762;&#x7684;&#x90E8;&#x5206;&#x5B57;&#x7B26;&#x4E32;&#x4F20;&#x7ED9;operatorURI&#xFF0C;pattern&#x548C;operatorURI&#x4F4D;&#x7F6E;&#x53EF;&#x4EE5;&#x8C03;&#x6362;&#x3002;</p>
<pre><code class="lang-sh"><span class="hljs-comment">#&#x5339;&#x914D;&#x6240;&#x6709;&#x8BF7;&#x6C42;</span>
/./ operatorURI

<span class="hljs-comment">#&#x5339;&#x914D;url&#x91CC;&#x9762;&#x5305;&#x542B;&#x6478;&#x4E2A;&#x5173;&#x952E;&#x5B57;&#x7684;&#x8BF7;&#x6C42;&#xFF0C;&#x4E14;&#x5FFD;&#x7565;&#x5927;&#x5C0F;&#x5199;</span>
/keyword/i operatorURI

<span class="hljs-comment"># &#x5229;&#x7528;&#x5B50;&#x5339;&#x914D;&#x628A;url&#x91CC;&#x9762;&#x7684;&#x53C2;&#x6570;&#x5E26;&#x5230;&#x5339;&#x914D;&#x7684;&#x64CD;&#x4F5C;uri</span>
<span class="hljs-comment"># &#x4E0B;&#x9762;&#x6B63;&#x5219;&#x5C06;&#x628A;&#x8BF7;&#x6C42;&#x91CC;&#x9762;&#x7684;&#x6587;&#x4EF6;&#x540D;&#x79F0;&#xFF0C;&#x5E26;&#x5230;&#x5339;&#x914D;&#x7684;&#x64CD;&#x4F5C;uri</span>
<span class="hljs-comment"># &#x6700;&#x591A;&#x652F;&#x6301;10&#x4E2A;&#x5B50;&#x5339;&#x914D; $0...9&#xFF0C;&#x5176;&#x4E2D;$0&#x8868;&#x793A;&#x6574;&#x4E2A;&#x8BF7;&#x6C42;url&#xFF0C;&#x5176;&#x5B83;&#x8DDF;&#x6B63;&#x5219;&#x7684;&#x5B50;&#x5339;&#x914D;&#x4E00;&#x6837;</span>
/[^?<span class="hljs-comment">#]\/([^\/]+)\.html/ protocol://...$1...</span>
</code></pre>
<blockquote>
<p>&#x6B63;&#x5219;&#x5339;&#x914D;&#x652F;&#x6301;&#x975E;&#x5339;&#x914D; !pattern&#x3002;</p>
</blockquote>
<h5 id="&#x7CBE;&#x786E;&#x5339;&#x914D;">&#x7CBE;&#x786E;&#x5339;&#x914D;</h5>
<p>&#x4E0E;&#x4E0A;&#x9762;&#x7684;&#x8DEF;&#x5F84;&#x5339;&#x914D;&#x4E0D;&#x540C;&#xFF0C;&#x8DEF;&#x5F84;&#x5339;&#x914D;&#x4E0D;&#x4EC5;&#x5339;&#x914D;&#x5BF9;&#x5E94;&#x7684;&#x8DEF;&#x5F84;&#xFF0C;&#x800C;&#x4E14;&#x8FD8;&#x4F1A;&#x5339;&#x914D;&#x8BE5;&#x8DEF;&#x5F84;&#x4E0B;&#x9762;&#x7684;&#x5B50;&#x8DEF;&#x5F84;&#xFF0C;&#x800C;&#x7CBE;&#x786E;&#x5339;&#x914D;&#x53EA;&#x80FD;&#x6307;&#x5B9A;&#x7684;&#x8DEF;&#x5F84;&#xFF0C;&#x53EA;&#x8981;&#x5728;&#x8DEF;&#x5F84;&#x524D;&#x9762;&#x52A0;$&#x5373;&#x53EF;&#x53D8;&#x6210;&#x7CBE;&#x786E;&#x5339;&#x914D;&#xFF0C;&#x7C7B;&#x4F3C;<code>$url operatorURI</code>&#xFF0C;pattern&#x548C;operatorURI&#x4F4D;&#x7F6E;&#x53EF;&#x4EE5;&#x8C03;&#x6362;&#x3002;</p>
<ul>
<li>&#x5305;&#x542B;&#x8BF7;&#x6C42;&#x534F;&#x8BAE;</li>
</ul>
<pre><code>  $http://www.test.com operatorURI
  $https://www.test.com/xxx? operatorURI
</code></pre><p>&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x5206;&#x522B;&#x53EA;&#x80FD;&#x5339;&#x914D;&#x8FD9;&#x4E24;&#x79CD;&#x8BF7;&#x6C42;&#xFF1A;</p>
<pre><code class="lang-sh">  http://www.test.com <span class="hljs-comment"># &#x6D4F;&#x89C8;&#x5668;&#x4F1A;&#x81EA;&#x52A8;&#x6539;&#x4E3A;http://www.test.com/</span>
  https://www.test.com/xxx?
</code></pre>
<ul>
<li>&#x4E0D;&#x5305;&#x542B;&#x8BF7;&#x6C42;&#x534F;&#x8BAE;</li>
</ul>
<pre><code> $www.test.com/xxx operatorURI
</code></pre><p>&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x53EF;&#x4EE5;&#x5339;&#x914D;&#x5982;&#x4E0B;&#x56DB;&#x79CD;&#x8BF7;&#x6C42;&#xFF1A;</p>
<pre><code>  http://www.test.com/xxx
  https://www.test.com/xxx
  ws://www.test.com/xxx
  wss://www.test.com/xxx
</code></pre><blockquote>
<p>&#x7CBE;&#x786E;&#x5339;&#x914D;&#x652F;&#x6301;&#x975E;&#x5339;&#x914D; <code>!$url</code>&#x3002;</p>
</blockquote>
<h5 id="&#x901A;&#x914D;&#x7B26;&#x5339;&#x914D;">&#x901A;&#x914D;&#x7B26;&#x5339;&#x914D;</h5>
<p>&#x57DF;&#x540D;&#x3001;&#x8DEF;&#x5F84;&#x5339;&#x914D;&#x4E0D;&#x80FD;&#x6EE1;&#x8DB3;&#x4E00;&#x4E9B;&#x590D;&#x6742;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x867D;&#x7136;&#x6B63;&#x5219;&#x5339;&#x914D;&#x53EF;&#x4EE5;&#x89E3;&#x51B3;&#x6240;&#x6709;&#x5339;&#x914D;&#x95EE;&#x9898;&#xFF0C;&#x4F46;&#x95E8;&#x69DB;&#x8FD8;&#x662F;&#x6709;&#x70B9;&#x9AD8;&#xFF0C;&#x4E14;&#x6D89;&#x53CA;&#x8F6C;&#x4E49;&#x53CA;&#x8BBE;&#x7F6E;&#x5339;&#x914D;&#x7684;&#x8D77;&#x59CB;&#x4F4D;&#x7F6E;&#x7B49;&#xFF0C;&#x5BF9;&#x4E00;&#x4E9B;&#x5E38;&#x7528;&#x5339;&#x914D;&#x5E95;&#x5C42;&#x5E93;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E9B;&#x66F4;&#x7B80;&#x5355;&#x7684;&#x914D;&#x7F6E;&#x65B9;&#x5F0F;&#xFF0C;&#x5305;&#x542B;<strong>&#x901A;&#x914D;&#x7B26;&#x5339;&#x914D;&#xFF0C;&#x901A;&#x914D;&#x57DF;&#x540D;&#x5339;&#x914D;&#x3001;&#x901A;&#x914D;&#x8DEF;&#x5F84;&#x5339;&#x914D;</strong>&#xFF1A;</p>
<ul>
<li>&#x901A;&#x914D;&#x7B26;&#x5339;&#x914D;&#xFF1A;</li>
</ul>
<p>&#x5339;&#x914D;&#x6A21;&#x5F0F;&#x5FC5;&#x987B;&#x4EE5; <code>^</code> &#x5F00;&#x5934;(&#x5982;&#x679C;&#x9700;&#x8981;&#x9650;&#x5236;&#x7ED3;&#x675F;&#x4F4D;&#x7F6E;&#x53EF;&#x4EE5;&#x7528; <code>$</code>)&#xFF0C;<code>*</code> &#x4E3A;&#x901A;&#x914D;&#x7B26;&#xFF0C;&#x652F;&#x6301;&#x901A;&#x8FC7;<code>$0...9</code>&#x83B7;&#x53D6;&#x901A;&#x914D;&#x7B26;&#x5339;&#x914D;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x5176;&#x4E2D;<code>$0</code>&#x8868;&#x793A;&#x6574;&#x4E2A;&#x8BF7;&#x6C42;url&#x3002;</p>
<pre><code class="lang-sh"><span class="hljs-comment"># &#x4EE5; ^ &#x5F00;&#x5934;</span>
^www.example.com/<span class="hljs-built_in">test</span>/*** referer://http://www.test.com/<span class="hljs-variable">$1</span>

<span class="hljs-comment"># &#x9650;&#x5B9A;&#x7ED3;&#x675F;&#x4F4D;&#x7F6E;</span>
^www.example.com/<span class="hljs-built_in">test</span>/***<span class="hljs-built_in">test</span>$ referer://http://www.test.com/<span class="hljs-variable">$1</span>
</code></pre>
<p>&#x5982;&#x679C;&#x8BF7;&#x6C42;url&#x4E3A; <code>https://www.example.com/test/abc?123test</code>&#xFF0C;&#x8FD9;&#x7B2C;&#x4E00;&#x4E2A;&#x914D;&#x7F6E; <code>$1 = abc?123&amp;test</code>&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x914D;&#x7F6E; <code>$1 = abc?123</code>&#xFF0C;&#x800C; <code>https://www.example.com/test/abc?123test2</code> &#x53EA;&#x80FD;&#x5339;&#x914D;&#x7B2C;&#x4E00;&#x4E2A;&#x3002;</p>
<p>&#x901A;&#x914D;&#x7B26;&#x5728;&#x8BF7;&#x6C42;url&#x91CC;&#x9762;&#x7684;&#x4E0D;&#x540C;&#x4F4D;&#x7F6E;&#x53CA;&#x4E2A;&#x6570;&#x5339;&#x914D;&#x7684;&#x5B57;&#x7B26;&#x7C7B;&#x578B;&#x4E5F;&#x4E0D;&#x4E00;&#x6837;&#xFF0C;&#x4E00;&#x822C;&#x8BF7;&#x6C42;url&#x7684;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre><code> protocol://domain/path?query
</code></pre><p>&#x5B8C;&#x6574;&#x901A;&#x914D;&#x7B26;&#x5339;&#x914D;&#xFF1A;</p>
<pre><code>^*://*.test.**.com:*/**?a=*&amp;**  opProtocol://opValue($0, $1, ..., $9)
</code></pre><p>&#x5176;&#x4E2D;&#xFF1A;$0&#x8868;&#x793A;&#x6574;&#x4E2A;&#x8BF7;&#x6C42;url&#xFF0C;$1...9&#x5206;&#x522B;&#x8868;&#x793A;&#x4ECE;&#x5DE6;&#x5230;&#x53F3;&#x7684;&#x901A;&#x914D;&#x7B26;&#x4E32;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x4E0D;&#x6307;&#x5B9A;&#x534F;&#x8BAE;&#xFF1A;</p>
<pre><code>^*/cgi-* operatorURI # &#x76F8;&#x5F53;&#x4E8E; /^\w+:\/\/([^./]*)\/cgi-(.*)/i  operatorURI
^**/cgi-* operatorURI # &#x76F8;&#x5F53;&#x4E8E; /^\w+:\/\/([^/]*)\/cgi-(.*)/i  operatorURI
</code></pre><ul>
<li>&#x5982;&#x679C;&#x901A;&#x914D;&#x7B26;&#x4E32;&#x5728;&#x8BF7;&#x6C42;url&#x7684;protocol&#x91CC;&#x9762;&#xFF0C;&#x4E0D;&#x7BA1;&#x662F;&#x4E00;&#x4E2A;&#x8FD8;&#x662F;&#x591A;&#x4E2A; <em> &#x90FD;&#x53EA;&#x80FD;&#x5339;&#x914D; [a-z\d]</em></li>
<li>&#x5982;&#x679C;&#x901A;&#x914D;&#x7B26;&#x4E32;&#x5728;domain&#x91CC;&#x9762;&#xFF0C;&#x4E00;&#x4E2A; <em> &#x8868;&#x793A;&#x5339;&#x914D; <sup><a href="#fn_/." id="reffn_/.">/.</a></sup>&#xFF0C;&#x4E24;&#x4E2A;&#x53CA;&#x4EE5;&#x4E0A;&#x7684; </em> &#x8868;&#x793A;&#x5339;&#x914D; <sup><a href="#fn_/" id="reffn_/">/</a></sup>*<ul>
<li>domain&#x91CC;&#x9762;&#x7684; <strong>*.xxx.yyy &#x76F8;&#x5F53;&#x4E8E; </strong>.xxx.yyy + xxx.yyy </li>
</ul>
</li>
<li>&#x5982;&#x679C;&#x901A;&#x914D;&#x7B26;&#x4E32;&#x5728;path&#x91CC;&#x9762;&#xFF0C;&#x4E00;&#x4E2A; <em> &#x8868;&#x793A;&#x5339;&#x914D; <sup><a href="#fn_/" id="reffn_/">/</a></sup>&#xFF0C;&#x4E24;&#x4E2A; </em> &#x8868;&#x793A;&#x5339;&#x914D; <sup><a href="#fn_&#xFF1F;" id="reffn_&#xFF1F;">&#xFF1F;</a></sup><em>&#xFF0C;&#x4E09;&#x4E2A;&#x53CA;&#x4EE5;&#x4E0A;&#x7684; </em> &#x8868;&#x793A;&#x5339;&#x914D; .*</li>
<li>&#x5982;&#x679C;&#x901A;&#x914D;&#x7B26;&#x4E32;&#x5728;query&#x91CC;&#x9762;&#xFF0C;&#x4E00;&#x4E2A; <em> &#x8868;&#x793A;&#x5339;&#x914D; <sup><a href="#fn_&amp;" id="reffn_&amp;">&amp;</a></sup>&#xFF0C;&#x4E24;&#x4E2A;&#x53CA;&#x4EE5;&#x4E0A;&#x7684; </em> &#x8868;&#x793A;&#x5339;&#x914D; .*</li>
</ul>
<blockquote>
<p>&#x901A;&#x914D;&#x7B26;&#x5339;&#x914D;&#x652F;&#x6301;&#x975E;&#x5339;&#x914D; !pattern&#x3002;</p>
</blockquote>
<h5 id="&#x901A;&#x914D;&#x57DF;&#x540D;&#x5339;&#x914D;&#xFF1A;">&#x901A;&#x914D;&#x57DF;&#x540D;&#x5339;&#x914D;&#xFF1A;</h5>
<pre><code class="lang-sh"><span class="hljs-comment"># &#x5339;&#x914D;&#x4E8C;&#x7EA7;&#x57DF;&#x540D;&#x4EE5; .com &#x7ED3;&#x5C3E;&#x7684;&#x6240;&#x6709;url&#xFF0C;&#x5982;: test.com, abc.com&#xFF0C;&#x4F46;&#x4E0D;&#x5305;&#x542B; *.xxx.com</span>
*.com file:///User/xxx/<span class="hljs-built_in">test</span>
//*.com file:///User/xxx/<span class="hljs-built_in">test</span>

<span class="hljs-comment"># &#x5339;&#x914D; test.com &#x7684;&#x5B50;&#x57DF;&#x540D;&#xFF0C;&#x4E0D;&#x5305;&#x62EC; test.com</span>
<span class="hljs-comment"># &#x4E5F;&#x4E0D;&#x5305;&#x62EC;&#x8BF8;&#x5982; *.xxx.test.com &#x7684;&#x56DB;&#x7EA7;&#x57DF;&#x540D;&#xFF0C;&#x53EA;&#x80FD;&#x5305;&#x542B;: a.test.com&#xFF0C;www.test.com &#x7B49;test.com&#x7684;&#x4E09;&#x7EA7;&#x57DF;&#x540D;</span>
*.test.com file:///User/xxx/<span class="hljs-built_in">test</span>
//*.test.com file:///User/xxx/<span class="hljs-built_in">test</span>

<span class="hljs-comment"># &#x5982;&#x679C;&#x8981;&#x914D;&#x7F6E;&#x6240;&#x6709;&#x5B50;&#x57DF;&#x540D;&#x751F;&#x6548;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; **</span>
**.com file:///User/xxx/<span class="hljs-built_in">test</span>
**.test.com file:///User/xxx/<span class="hljs-built_in">test</span>

<span class="hljs-comment"># &#x9650;&#x5B9A;&#x534F;&#x8BAE;&#xFF0C;&#x53EA;&#x5BF9;http&#x751F;&#x6548;</span>
http://*.com file:///User/xxx/<span class="hljs-built_in">test</span>
http://**.com file:///User/xxx/<span class="hljs-built_in">test</span>
http://*.test.com file:///User/xxx/<span class="hljs-built_in">test</span>
http://**.test.com file:///User/xxx/<span class="hljs-built_in">test</span>

<span class="hljs-comment"># &#x8DEF;&#x5F84;</span>
*.com/abc/efg file:///User/xxx/<span class="hljs-built_in">test</span>
**.com/abc/efg file:///User/xxx/<span class="hljs-built_in">test</span>
*.test.com/abc/efg file:///User/xxx/<span class="hljs-built_in">test</span>
**.test.com/abc/efg file:///User/xxx/<span class="hljs-built_in">test</span>

http://*.com/abc/efg file:///User/xxx/<span class="hljs-built_in">test</span>
http://**.com/abc/efg file:///User/xxx/<span class="hljs-built_in">test</span>
http://*.test.com/abc/efg file:///User/xxx/<span class="hljs-built_in">test</span>
http://**.test.com/abc/efg file:///User/xxx/<span class="hljs-built_in">test</span>
</code></pre>
<h5 id="&#x901A;&#x914D;&#x8DEF;&#x5F84;&#x5339;&#x914D;&#xFF1A;">&#x901A;&#x914D;&#x8DEF;&#x5F84;&#x5339;&#x914D;&#xFF1A;</h5>
<pre><code class="lang-sh"><span class="hljs-comment"># &#x5BF9;&#x6240;&#x6709;&#x57DF;&#x540D;&#x5BF9;&#x5E94;&#x7684;&#x8DEF;&#x5F84; protocol://a.b.c/xxx[/yyy]&#x90FD;&#x751F;&#x6548;</span>
*/ 127.0.0.1
*/xxx 127.0.0.1:9999
tunnel://*/ 127.0.0.1:9999 <span class="hljs-comment"># tunnel&#x53EA;&#x652F;&#x6301;&#x6839;&#x8DEF;&#x5F84;&#x5339;&#x914D;</span>
http://*/ 127.0.0.1
https://*/xxx 127.0.0.1
ws://*/xxx 127.0.0.1
wss://*/xxx 127.0.0.1

<span class="hljs-comment"># &#x4E5F;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x8DEF;&#x5F84;&#xFF0C;&#x4E0D;&#x5305;&#x542B;&#x8BE5;&#x8DEF;&#x5F84;&#x7684;&#x5B50;&#x8DEF;&#x5F84;</span>
$*/ 127.0.0.1
$*/xxx 127.0.0.1:9999
<span class="hljs-variable">$tunnel</span>://*/  127.0.0.1 <span class="hljs-comment"># tunnel&#x53EA;&#x652F;&#x6301;&#x6839;&#x8DEF;&#x5F84;&#x5339;&#x914D;</span>
<span class="hljs-variable">$http</span>://*/ 127.0.0.1:9999
<span class="hljs-variable">$https</span>://*/xxx 127.0.0.1:9999
<span class="hljs-variable">$ws</span>://*/xxx 127.0.0.1:9999
<span class="hljs-variable">$wss</span>://*/xxx 127.0.0.1
</code></pre>
<p>&#x5982;&#xFF1A; <code>*/cgi-bin 10.10.1.1:9999</code>&#xFF0C;&#x8868;&#x793A;&#x6240;&#x6709; <code>xxx.xxx.xxx/cgi-bin/xxx</code> &#x7684;&#x8BF7;&#x6C42;&#x90FD;&#x4F1A;&#x8BF7;&#x6C42; <code>10.10.1.1:9999</code> &#x5BF9;&#x5E94;&#x7684;&#x670D;&#x52A1;&#x5668;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="rule-model.html" class="navigation navigation-prev " aria-label="Previous page: 6.1 配置方式">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="rule-opv.html" class="navigation navigation-next " aria-label="Next page: 6.3 操作值 opValue">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"6.2 匹配模式 pattern","level":"1.6.2","depth":2,"next":{"title":"6.3 操作值 opValue","level":"1.6.3","depth":2,"path":"rule-opv.md","ref":"rule-opv.md","articles":[]},"previous":{"title":"6.1 配置方式","level":"1.6.1","depth":2,"path":"rule-model.md","ref":"rule-model.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"css/default.css"},"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"language":"zh-hans","gitbook":"*"},"file":{"path":"rule-pattern.md","mtime":"2019-11-05T10:48:13.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-12-17T11:59:46.789Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

